home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.border;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Graphics;
- import java.awt.Insets;
-
- public class EtchedBorder extends AbstractBorder {
- public static final int RAISED = 0;
- public static final int LOWERED = 1;
- protected int etchType;
- protected Color highlight;
- protected Color shadow;
-
- public EtchedBorder() {
- this(1);
- }
-
- public EtchedBorder(int etchType) {
- this(etchType, (Color)null, (Color)null);
- }
-
- public EtchedBorder(int etchType, Color highlight, Color shadow) {
- this.etchType = etchType;
- this.highlight = highlight;
- this.shadow = shadow;
- }
-
- public EtchedBorder(Color highlight, Color shadow) {
- this(1, highlight, shadow);
- }
-
- public Insets getBorderInsets(Component c) {
- return new Insets(2, 2, 2, 2);
- }
-
- public int getEtchType() {
- return this.etchType;
- }
-
- public Color getHighlightColor(Component c) {
- return this.highlight != null ? this.highlight : c.getBackground().brighter();
- }
-
- public Color getShadowColor(Component c) {
- return this.shadow != null ? this.shadow : c.getBackground().darker();
- }
-
- public boolean isBorderOpaque() {
- return true;
- }
-
- public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
- g.translate(x, y);
- g.setColor(this.etchType == 1 ? this.getShadowColor(c) : this.getHighlightColor(c));
- g.drawRect(0, 0, width - 2, height - 2);
- g.setColor(this.etchType == 1 ? this.getHighlightColor(c) : this.getShadowColor(c));
- g.drawLine(1, height - 3, 1, 1);
- g.drawLine(1, 1, width - 3, 1);
- g.drawLine(0, height - 1, width - 1, height - 1);
- g.drawLine(width - 1, height - 1, width - 1, 0);
- g.translate(-x, -y);
- }
- }
-